const mutations = {

    // 添加收藏
    addCollect(state, obj) {

        for (let i = 0; i < state.collectList.length; i++) {
            if (state.collectList[i].id == obj.id) {

                return
            }
        }

        state.collectList.unshift(obj)
        localStorage.setItem('collection', JSON.stringify(state.collectList))
    },
    // 取消或删除收藏
    removeCollect(state, id) {
        for (let i = 0; i < state.collectList.length; i++) {
            if (state.collectList[i].id == id) {
                state.collectList.splice(i, 1)
                localStorage.setItem('collection', JSON.stringify(state.collectList))
                return
            }
        }
    }

    // 
}

export default mutations